unit Unit1;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, RzTabs, Vcl.Buttons, Vcl.StdCtrls;

type
  TForm1 = class(TForm)
    grp1: TGroupBox;
    lstPlugins: TListBox;
    mmo1: TMemo;
    btnLoadPlugins: TButton;
    btnUnload: TButton;
    btnShowPlug: TButton;
    edt1: TEdit;
    btnShowPlugName: TButton;
    btnGetForm: TButton;
    btnCloseForm: TButton;
    btnClosePluginName: TButton;
    btn1: TBitBtn;
    RzPageControl1: TRzPageControl;
    tstTabSheet1: TRzTabSheet;
    tstTabSheet2: TRzTabSheet;
    procedure btnLoadPluginsClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.btnLoadPluginsClick(Sender: TObject);
var
  counter: integer;
  Plug: TJvPlugin;
  MyPlug: IMyPlugInInterface;
begin
  btnLoadPlugins.Enabled := False;

  // Loading Plugins
  mmo1.Lines.Add('Looking in ' + ExtractFilePath(Application.Exename) +
    ' for Plugins');
  uilPluginManager1.LoadPlugins;
  mmo1.Lines.Add(IntToStr(uilPluginManager1.PluginCount) + ' plugins loaded.');

  // Check if plugins have correct interface
  counter := 0;
  while counter < uilPluginManager1.PluginCount do
  begin
    Plug := uilPluginManager1.Plugins[counter];
    if Plug.GetInterface(IMyPlugInInterface, MyPlug) then
    begin
      mmo1.Lines.Add(IntToStr(counter) + ' : ' + Plug.Description + ' V ' +
        Plug.PluginVersion);
      lstPlugins.Items.Add(Plug.Description + ' V ' + Plug.PluginVersion);

      Plug.Configure;
      LstPlugs.Add(Plug.Description, MyPlug);
      LstPlugs[Plug.Description].Init(self,Screen);
      //MyPlug.Init(Self);
      // MyPlug.Init(Self,Screen); // make the plugin aware of the main app
      Inc(counter);
    end
    else
    begin
      mmo1.Lines.Add('Warning : Plugin ' + Plug.Description +
        ' has unknown interface - unloaded!');
      uilPluginManager1.UnloadPlugin(counter);
    end;
  end;
  if (lstPlugins.ItemIndex < 0) then
    lstPlugins.ItemIndex := 0;
end;

end.
